import java.util.ArrayList;
import java.util.Collections;


public class bublesort {
	public static int num = 10;
	public static ArrayList<Integer> list = new ArrayList<Integer> (num);
	
	public static ArrayList<Integer> justbubsor(){
		int t = num - 1;
		for(int j = 0;j < t; j++){
			for(int i = 0;i < t; i++){
				if(list.get(i) > list.get(i + 1)){
					int tmp = list.get(i);
					list.set(i, list.get(i + 1)); //a[i] = a[i + 1]
					list.set(i+1, tmp);}
			}
		}
		return list;
	}
	public static ArrayList<Integer> flagbubsor(){
		int t = num - 1;
		int flag = t;
		for(int j = 0; j < flag ; j++){
			
			for(int i = 0; i < t; i++){
				if(list.get(i) > list.get(i + 1)){
					int tmp = list.get(i);
					list.set(i, list.get(i + 1)); //a[i] = a[i + 1]
					list.set(i+1, tmp);             //a[i + 1] = tmp
					
				}
			}
			flag--;
		}
		return list;
		
	}
	public static void main(String[] args) {
		
		for (int i = 0; i < num; i++){
			list.add(i);
		}
		Collections.shuffle(list);
		System.out.println(list);
		long start = System.nanoTime();
		flagbubsor();
		long estTime = System.nanoTime() - start;
		System.out.println(estTime);
		System.out.println(list);
		}
		
}
